﻿#ifndef TEXTEDIT_H
#define TEXTEDIT_H
#include <QTextEdit>

class TextEdit : public QTextEdit
{
    Q_OBJECT
public:
    TextEdit(QWidget*parent=nullptr);
    ~TextEdit();

public:
    void initNewDoc();
    QString getDocFilePath()const;
    bool loadDoc(const QString&docName);
    QString getDocName()const;
    bool saveDoc();
    bool saveAsDoc();
    QString getDocWindowTitle()const;

protected:
    void closeEvent(QCloseEvent*event)override;

private:
    void initOpenDoc(const QString&docName);
    bool writeToDoc(const QString &docName);
    bool promptSave();

private slots:
    void setWindowModify();

private:
    QString docwindowTiele;
    static int docNo;
    QString docFilePath;
};

#endif // TEXTEDIT_H
